Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Making run-time references with DYNAMIC-FUNCTION

Progress lets you construct a reference to a function at run time, using a built-in function called DYNAMIC-FUNCTION. Here’s the syntax:

DYNAMIC-FUNCTION ( function [ IN handle ] [ , parameters ] ) 

Like a function reference itself, the DYNAMIC-FUNCTION function can appear anywhere in your procedure code where an expression of that data type could appear.

The first parameter to DYNAMIC-FUNCTION is the name of the function to invoke. This procedure can be a quoted literal or an expression, such as a variable that evaluates to a valid function name.

Following this, you can optionally include an IN handle phrase to direct Progress to execute the function in a persistent procedure handle. In this case, the handle must be an actual field or variable name of HANDLE data type, not an expression.

If the function itself takes any parameters, you pass those as additional parameters to DYNAMIC-FUNCTION, in the same form that you would pass them to the function itself.

DYNAMIC-FUNCTION gives you the flexibility to have code that can execute different function names depending on the situation, since the function parameter can be a variable. You might have, for example, several different functions that do parallel work for different categories of data in a loop you’re iterating through. However, that is of perhaps limited value because all the functions you invoke must have the same signature.

The most common use of DYNAMIC-FUNCTION is for one of two other reasons:


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095